package com.eaoa.uc.document.form;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.upload.FormFile;

import com.eaoa.base.EABaseForm;
import com.eaoa.vo.pub.PubDocument;
import com.eaoa.vo.pub.PubModule;
import com.stony.core.util.CoreUtils;

public class PubdocumentForm extends EABaseForm {

	private String documentno;

	private String title;

	private String content;

	private String documenttype;

	private String remarks;

	private String createdate;

	private String createby;

	private String createbyname;

	private String moduleno;
	
	private String topmodule;
	
	
	private FormFile formfile;
	
	public PubDocument getVO() {

		PubDocument vo = new PubDocument();

		vo.setDocumentno(CoreUtils.parseLong(this.documentno));

		vo.setTitle(this.getTitle());

		vo.setContent(this.getContent());

		vo.setDocumenttype(this.getDocumenttype());

		vo.setCreateby(CoreUtils.parseLong(this.getCreateby()));

		vo.setCreatedate(CoreUtils.parseDate(this.getCreatedate()));

		vo.setCreatebyname(this.getCreatebyname());

		vo.setRemarks(this.getRemarks());
		
		vo.setModuleno(CoreUtils.parseLong(this.getModuleno()));

		if (StringUtils.isNotBlank(this.getModuleno()))
			vo.setPubModule(new PubModule(CoreUtils.parseLong(getModuleno())));
		
		return vo;

	}

	public void setVO(PubDocument vo) {

		this.setDocumentno(vo.getDocumentno().toString());

		this.setTitle(vo.getTitle());

		this.setContent(vo.getContent());

		this.setDocumenttype(vo.getDocumenttype());

		this.setCreatebyname(vo.getCreatebyname());

		this.setRemarks(vo.getRemarks());

		if (vo.getPubModule() != null){
			this.setModuleno(CoreUtils.formatString(vo.getPubModule().getModuleno()));
			String modulepath = vo.getPubModule().getModulepath();
			if(StringUtils.isNotBlank(modulepath)){
				String[] modulepaths = modulepath.split(",");
				if(modulepaths.length>1 )
					this.setTopmodule(modulepaths[1]);
			}
		}

			
		this.setCreatedate(CoreUtils.formatDate(vo.getCreatedate()));

		this.setCreateby(CoreUtils.formatString(vo.getCreateby()));
			
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getDocumentno() {
		return documentno;
	}

	public void setDocumentno(String documentno) {
		this.documentno = documentno;
	}

	public String getDocumenttype() {
		return documenttype;
	}

	public void setDocumenttype(String documenttype) {
		this.documenttype = documenttype;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getCreateby() {
		return createby;
	}

	public void setCreateby(String createby) {
		this.createby = createby;
	}

	public String getCreatebyname() {
		return createbyname;
	}

	public void setCreatebyname(String createbyname) {
		this.createbyname = createbyname;
	}

	public String getCreatedate() {
		return createdate;
	}

	public void setCreatedate(String createdate) {
		this.createdate = createdate;
	}

	public FormFile getFormfile() {
		return formfile;
	}

	public void setFormfile(FormFile formfile) {
		this.formfile = formfile;
	}

	public String getModuleno() {
		return moduleno;
	}

	public void setModuleno(String moduleno) {
		this.moduleno = moduleno;
	}

	public String getTopmodule() {
		return topmodule;
	}

	public void setTopmodule(String topmodule) {
		this.topmodule = topmodule;
	}


}
